﻿// Decompiled with JetBrains decompiler
// Type: TaleWorlds.MountAndBlade.View.PopupSceneEmissionHandler
// Assembly: TaleWorlds.MountAndBlade.View, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: 61152EB8-513B-4D4A-8AC0-0D1465C6CF6C
// Assembly location: D:\steam\steamapps\common\Mount & Blade II Bannerlord\Modules\Native\bin\Win64_Shipping_Client\TaleWorlds.MountAndBlade.View.dll

using TaleWorlds.DotNet;
using TaleWorlds.Engine;
using TaleWorlds.Library;

#nullable disable
namespace TaleWorlds.MountAndBlade.View
{
  public class PopupSceneEmissionHandler : ScriptComponentBehavior
  {
    public float startTime;
    public float transitionTime;
    private float timeElapsed;

    protected override void OnInit()
    {
      base.OnInit();
      this.SetScriptComponentToTick(this.GetTickRequirement());
    }

    protected override void OnEditorInit() => base.OnEditorInit();

    public override ScriptComponentBehavior.TickRequirement GetTickRequirement()
    {
      return ScriptComponentBehavior.TickRequirement.Tick;
    }

    protected override void OnTick(float dt)
    {
      this.timeElapsed += dt;
      foreach (GameEntity child in this.GameEntity.GetChildren())
      {
        Mesh firstMesh = child.GetFirstMesh();
        if ((NativeObject) firstMesh != (NativeObject) null)
          firstMesh.SetVectorArgument(1f, 0.5f, 1f, MBMath.SmoothStep(this.startTime, this.startTime + this.transitionTime, this.timeElapsed) * 10f);
      }
    }

    protected override void OnEditorTick(float dt)
    {
      base.OnEditorTick(dt);
      this.OnTick(dt);
    }
  }
}
